package com.xinzhi.savingpot.task.controller;


import com.xinzhi.savingpot.task.vo.TaskInfoVo;
import com.xinzhi.savingpot.task.service.impl.TaskinfoServiceImpl;

import com.xinzhi.savingpot.util.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.io.IOException;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author astupidcoder
 * @since 2021-01-05
 */
@RestController
@Api("任务")
@RequestMapping("/taskInfo")
@CrossOrigin
public class TaskinfoController {

    @Autowired
    private TaskinfoServiceImpl taskService;

    @ApiOperation("发布任务")
    @PostMapping("/addTask")
    public BaseResponse addTask(@Valid @RequestBody TaskInfoVo tiv, @RequestParam("userID") Integer userID){
        return taskService.addTask(tiv, userID);
    }



    @ApiOperation("根据任务ID获取任务详细信息")
    @GetMapping("/getTaskById")
    public BaseResponse queryTaskInfo(@RequestParam("taskId") Integer taskId) throws IOException {
        return taskService.queryTaskInfo(taskId);
    }

}
